package mlz.a_threadapi;

public class Demo02 {
    public static void main(String[] args) throws InterruptedException {

        //让主线程休眠
        System.out.println("主线程休眠前....");
        Thread.sleep(3000);
        System.out.println("主线程休眠后....");

        Runnable r = new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    //毫秒值 1秒 = 1000毫秒
                    try {
                        Thread.sleep(3000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    Thread t = Thread.currentThread();
                    System.out.println(t.getName() + ":" + i);
                }
            }
        };

        Thread t = new Thread(r);
        t.start();
    }
}
